package bluetooth.adapter;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import bluetooth.main.R;
import bluetooth.model.Product;

public class ListDataAdapter extends BaseAdapter {

	private List<Product> itemDetailsrrayList;
	private LayoutInflater l_Inflater;

	  
	  public ListDataAdapter( List<Product> paramArrayList,Activity activity)
	  {
	    itemDetailsrrayList = paramArrayList;
	    this.l_Inflater = LayoutInflater.from(activity);
	   
	  }

	  public int getCount()
	  {
	    return itemDetailsrrayList.size();
	  }

	  public Object getItem(int paramInt)
	  {
	    return itemDetailsrrayList.get(paramInt);
	  }

	  public long getItemId(int paramInt)
	  {
	    return paramInt;
	  }


	  
	  public View getView(int position, View convertView, ViewGroup parent) {
	      ViewHolder holder;
	      if (convertView == null) {
	              convertView = l_Inflater.inflate(R.layout.data_row, null);
	              holder = new ViewHolder();
	              holder.txtName=(TextView)convertView.findViewById(R.id.textViewName_row);
	              //holder.txtCategory=(TextView)convertView.findViewById(R.id.textViewCategory_row); 
	              //holder.txtPrice=(TextView)convertView.findViewById(R.id.textViewPrice_row);  
	              convertView.setTag(holder);
	      } else {
	              holder = (ViewHolder) convertView.getTag();
	      }
	      
	     // holder.txtCategory.setText(itemDetailsrrayList.get(position).getCategory().getName());
	      holder.txtName.setText(itemDetailsrrayList.get(position).getName()); 
	      //holder.txtPrice.setText(String.valueOf(itemDetailsrrayList.get(position).getPrice())); 
	      return convertView;
	}

	  static class ViewHolder
	  {
	         TextView txtName;
	         TextView txtPrice;
	         TextView txtCategory;
	  }
}
